home *** CD-ROM | disk | FTP | other *** search
- From: "Martin E. Nordberg III" <102571.1562@CompuServe.COM>
- Message-ID: <4isb5a$ct4$1@mhafc.production.compuserve.com>
- X-Original-Date: 21 Mar 1996 19:37:14 GMT
- Path: in1.uu.net!bounce-back
- Date: 22 Mar 96 02:20:54 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: dynamic_cast<const B&>
- Organization: Quintessoft Engineering, Inc.
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMVIOpOEDnX0m9pzZAQH4mAF/evelZ8rALzE0czYno0nvUJ6WQs8lpqEy
- E5gmiR+Yg34TX9UAWqNVMyksUDdmFwwn
- =V9c4
-
- I just installed MS VC++ 4.1. The following code (strained
- from my larger code) now fails to compile:
-
- class A { virtual ~A() };
- class B : public A {};
-
- void test( const A& a )
- {
- const B& b = dynamic_cast<const B&>( a );
- // gives "... error ... cannot use dynamic_cast to
- // convert from 'const A &' to 'const B &' "
- }
-
- Did Microsoft goof or did I? The draft standard (Sect. 5.2.6)
- seems to equate a reference to an lvalue for dynamic_cast, but
- gives no clear wording for this case. The same problem happens
- for const A* to const B*.
- If the new MSVC++ behavior is correct, why?
- (Eagerly awaiting BC++ 5.0, hope it really works with MFC)
-
- --
- Martin E. Nordberg III
- Quintessoft Engineering, Inc.
- "Visualizing new patterns of software development."
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-